package com.jxc.service.impl;

import java.util.List;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
import org.springframework.stereotype.Service;

import com.jxc.model.po.Jhtj;
import com.jxc.model.po.User;
import com.jxc.model.po.Xstj;
import com.jxc.service.DealerTotalServiceI;

@Service("dealerTotalService")
public class DealerTotalServiceImp implements DealerTotalServiceI {

	public JFreeChart getChart(List<Jhtj> list) {
		try {
			DefaultCategoryDataset dataset = new DefaultCategoryDataset();
			for(Jhtj jhtj:list){
				System.out.println(jhtj.getJhsum());
				dataset.addValue(jhtj.getJhsum(), jhtj.getRealname(), jhtj.getRealname());
			}
			return  ChartFactory.createBarChart3D("经销商进货统计图",
			  "经销商",
			  "进货量",
			  dataset,
			  PlotOrientation.VERTICAL,
			  true,
			  true,
			  true);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public JFreeChart getXsChart(List<Xstj> list) {
		try {
			DefaultCategoryDataset dataset = new DefaultCategoryDataset();
			for(Xstj jhtj:list){
				dataset.addValue(jhtj.getXssum(), jhtj.getRealname(), jhtj.getRealname());
			}
			return  ChartFactory.createBarChart3D("经销商销售统计图",
			  null,
			  null,
			  dataset,
			  PlotOrientation.VERTICAL,
			  true,
			  false,
			  false);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
